package com.qianfeng.smartmeeting.controller;

import com.qianfeng.smartmeeting.dto.LoginDto;
import com.qianfeng.smartmeeting.dto.RegisterDto;
import com.qianfeng.smartmeeting.service.AuthService;
import com.qianfeng.smartmeeting.utils.ResponseResult;
import com.qianfeng.smartmeeting.vo.LoginVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/api/auth")
public class AuthController {
    @Autowired
    private AuthService authService;
    
    @PostMapping("/login")
    public ResponseResult<LoginVo> login(@Valid @RequestBody LoginDto loginDto) {
        return authService.login(loginDto);
    }
    
    @PostMapping("/register")
    public ResponseResult<?> register(@Valid @RequestBody RegisterDto registerDto) {
        return authService.register(registerDto);
    }
}